package com.cn.chaomeng.service.impl;

import com.cn.chaomeng.dao.UserMapper;
import com.cn.chaomeng.model.User;
import com.cn.chaomeng.model.example.UserExample;
import com.cn.chaomeng.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author LYJ
 *         Created by Administrator on 2018/3/7 0007.
 */
@Service("userService")
public class UserServiceImpl implements IUserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public User selectByOpenId(String openId) {
        UserExample userExample = new UserExample();
        userExample.createCriteria().andOpenidEqualTo(openId);
        List<User> users = userMapper.selectByExample(userExample);
        if(users != null && users.size() != 0){
            return users.get(0);
        }
        return null;
    }
}
